/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.fallback.system;

import com.enation.app.javashop.core.client.feignimpl.system.EmailClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import com.enation.app.javashop.model.base.SceneType;
import com.enation.app.javashop.model.base.vo.EmailVO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author fk
 * @version v2.0
 * @Description: 邮件断路器
 * @date 2018/9/27 9:26
 * @since v7.0.0
 */
@Component
public class EmailClientFallbackFactory extends BaseFallbackFactory<EmailClientFeignImpl> implements FallbackFactory {


    @Override
    protected EmailClientFeignImpl fallback() {
        return new EmailClientFallback();
    }

    /**
     * @author fk
     * @version v2.0
     * @Description: 邮件断路器
     * @date 2018/9/27 9:26
     * @since v7.0.0
     */
    @Component
    public static class EmailClientFallback implements EmailClientFeignImpl {

        protected final Log logger = LogFactory.getLog(this.getClass());

        @Override
        public void sendEmail(EmailVO emailVO) {

            this.logger.error("系统服务返回异常，发送邮件异常");
        }

        @Override
        public boolean valid(String scene, String email, String code) {

            this.logger.error("系统服务返回异常，邮件验证异常");
            return false;
        }

        @Override
        public void sendEmailMessage(String byName, String email, SceneType sceneType) {
            this.logger.error("系统服务返回异常，sendEmail异常");

        }
    }
}
